package com.clip.dao;
// default package

import java.util.List;

import org.hibernate.LockMode;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.clip.entity.ForbiddenEvent;
import com.clip.entity.virtual.EventForView;

@Repository
public class ForbiddenEventDAO extends BasicDao  {

    public static final String UID = "uid";

    public static final String EVENTID="eventid";
    public void save(ForbiddenEvent transientInstance) {
        try {
            getSession().save(transientInstance);
        } catch (RuntimeException re) {
            throw re;
        }
    }
    
	public void delete(ForbiddenEvent persistentInstance) {
        try {
            getSession().delete(persistentInstance);
        } catch (RuntimeException re) {
            throw re;
        }
    }
    
    public ForbiddenEvent findById( java.lang.Integer id) {
        try {
        	ForbiddenEvent instance = (ForbiddenEvent) getSession()
                    .get(ForbiddenEvent.class, id);
            return instance;
        } catch (RuntimeException re) {
            throw re;
        }
    }
    
    public List findByProperty(String propertyName, Object value) {
      try {
         String queryString = "from ForbiddenEvent as model where model." 
         						+ propertyName + "= ?";
         Query queryObject = getSession().createQuery(queryString);
		 queryObject.setParameter(0, value);
		 return queryObject.list();
      } catch (RuntimeException re) {
         throw re;
      }
	}

	public List findByUid(Object uid
	) {
		return findByProperty(UID, uid
		);
	}
	
	public List findByEventid(Object eventid
	) {
		return findByProperty(EVENTID, eventid
		);
	}
	

	public List findAll() {
		try {
			String queryString = "from ForbiddenEvent";
	         Query queryObject = getSession().createQuery(queryString);
			 return queryObject.list();
		} catch (RuntimeException re) {
			throw re;
		}
	}
	
    public ForbiddenEvent merge(ForbiddenEvent detachedInstance) {
        try {
        	ForbiddenEvent result = (ForbiddenEvent) getSession()
                    .merge(detachedInstance);
            return result;
        } catch (RuntimeException re) {
            throw re;
        }
    }

    public void attachDirty(ForbiddenEvent instance) {
        try {
            getSession().saveOrUpdate(instance);
        } catch (RuntimeException re) {
            throw re;
        }
    }
    
    public void attachClean(ForbiddenEvent instance) {
        try {
            getSession().lock(instance, LockMode.NONE);
        } catch (RuntimeException re) {
            throw re;
        }
    }

	public List findByQuery(String query) {
		return getSession().createQuery(query).list();
	}
}